/**
 * Created by 魏爷 on 2016/6/6.
 */
$(function(){
    var url=$('#forum-url').val();
    var del_url=$('#del-url').val();
    var app={
        add:function(obj){
            var loading=layer.load(1);
            $.post(
                url,
                {feel_id:obj.attr('data-id'),forum_content:$('#forum_content').val()},
                function(res){
                    layer.close(loading);
                    if(res.status==1){
                        layer.msg(res.info,{icon:1});
                        window.location.reload();
                    }else{
                        layer.msg(res.info,{icon:2});
                        window.location.reload();
                    }
                });
        },
        del:function(obj){
            var loading=layer.load(1);
            $.post(
                del_url,
                {forum_id:obj.attr('data-del-id')},
                function(res){
                    layer.close(loading);
                    if(res.status==1){
                        layer.msg(res.info,{icon:1});
                        window.location.reload();
                    }else{
                        layer.msg(res.info,{icon:2});
                        window.location.reload();
                    }
                });
        },

    }
    $('.add').click(function () {
        app.add($(this));
    });
    $('.del').click(function () {
        app.del($(this));
    });
});
